package com.qn.entity.dto;

import cn.crane4j.annotation.AssembleMethod;
import cn.crane4j.annotation.ContainerMethod;
import com.qn.entity.User;
import com.qn.service.UserService;
import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class UserDTO {

    /**
     * 主键ID
     */
    // 1、根据id从方法中获取对应的对象，然后将其name映射到当前的name中
//    @Assemble(container = "user", props = @Mapping("userName"))
    @AssembleMethod(
            targetType = UserService.class, // 填充数据源为 CustomerService#listByIds 方法
            method = @ContainerMethod(bindMethod = "listByIds", resultType = User.class),
            prop = {
                    "name:userName" // Customer.name -> Order.customerName
            }
    )
    private Long id;

    /**
     * 姓名
     */
//    @AssembleMp(
//            mapper = "userMapper",
//            selects = {"name", "email"}, // 要查询的字段
//            props = @Mapping(src = "name", ref = "userName")
    /// /            props = {
    /// /                    @Mapping(src = "name", ref = "userName"),
    /// /                    @Mapping(src = "email", ref = "email")
    /// /            }
//    )

//    @Assemble(container = "user", props = @Mapping(src = "user", ref = "userName"))

//    @AssembleMethod(
//            targetType = UserService.class, // 填充数据源为 CustomerService#listByIds 方法
//            method = @ContainerMethod(bindMethod = "listByIds", resultType = User.class),
//            prop = {
//                    "name:userName" // Customer.name -> Order.customerName
//            }
//    )
    private String userName;

    /**
     * 年龄
     */
    private Integer age;

    /**
     * 邮箱
     */
    private String email;

}
